

#ifndef THREAD_SEARCH_THREAD_H
#define THREAD_SEARCH_THREAD_H

#include <wx/thread.h>
#include <wx/dir.h>
#include <wx/arrstr.h>

#include "ThreadSearchFindData.h"
#include "ThreadSearch.h"
#include "ThreadSearchView.h"


class wxString;

class cbProject;
class cbStyledTextCtrl;

class TextFileSearcher;
class ThreadSearchView;
class ThreadSearchThread;


class ThreadSearchThread : public wxThread, public wxDirTraverser
{
public:
	
	ThreadSearchThread(ThreadSearchView* pThreadSearchView, const ThreadSearchFindData& findData);

	
	~ThreadSearchThread();

	
	void OnExit();

	ThreadSearchView* GetThreadSearchView(){return m_pThreadSearchView;}    
protected:
	
	void *Entry();

private:
	
	wxDirTraverseResult OnDir(const wxString& dirName);

	
	wxDirTraverseResult OnFile(const wxString& fileName);

	
	void FindInFile(const wxString& path);

	
    static bool AddNewItem(wxSortedArrayString& sortedArrayString, const wxString& newItem);

    
    void AddSnippetFiles(wxSortedArrayString& sortedArrayString, cbProject& project);

	ThreadSearchView*    m_pThreadSearchView; // Worker thread caller
	ThreadSearchFindData m_FindData;          
	wxDirTraverseResult  m_DefaultDirResult;  // Used to recurse or not in directory search
	wxArrayString        m_LineTextArray;     // Array containing one file search results.
                                              // Succession of 'line number' and line of text
	wxArrayString        m_Masks;             // Used in directory search to filter file paths.
	wxSortedArrayString  m_FilePaths;         // Array containing all file paths that will be
	                                          // searched in.
	TextFileSearcher*    m_pTextFileSearcher; // Searcher object
};


#endif // THREAD_SEARCH_THREAD_H
